perm filename CHAIN.L70[L70,TES] blob sn#009947 filedate 1972-06-27 generic text, type T, neo UTF8
00100	
00200	EXPERIMENTAL P-STACK PLAN
00300	
00400	Every function call (except calls on EXEMPT functions such as
00500	most system functiions) will be preceded by a:
00600		PUSH P, XWD(-(L+1), L+A+2)
00700	where L is the number of temps and locals since the return address
00800	of the caller and A is the number of caller arguments stored under that
00900	return address.  Thus, the stack looks like this when DPNT(FLABEL)
01000	has just been called:
01100	
01200			|---------------|
01300		P >>>>>>       RA	|
01400			|---------------|
01500			|    FLABEL	|
01600			|---------------|
01700			|-(L0+1)|L0+A0+2|
01800			|---------------|
01900			|		|
02000			|    L0 WORDS	|
02100			|		|
02200			|---------------|
02300			|      RA	|
02400			|---------------|
02500			|		|
02600			|    A0 WORDS	|
02700			|		|
02800			|---------------|
02900			|-(L1+1)|L1+A1+2|
03000			|---------------|
03100			|		|
03200			|    L1 WORDS	|
03300			|		|
03400			|---------------|
03500			|      RA	|
03600			|---------------|
03700			|		|
03800			|    A1 WORDS	|
03900			|		|
04000			|---------------|
04100			|-(L2+1)|L2+A2+2|
04200			|---------------|
04300			|		|
     

00100	DPNT pops the top RA off P and saves it.
00200		POP P, RA
00300	It creates a new context on SS, saving vital pointers.
00400		PUSH SS, CBASE
00500		MOVEM SS, CBASE
00600		PUSH SS, CTAG
00700		ADDI CTAG, 8
00800		PUSH SS, =REVERT
00900	Then it searches P for an XWD at least MINBLT away.
01000		MOVEI REG2, 0		MEASURE
01100		HRRI VAL, -1(P)		XWD LOCATION
01200	NEXTXWD	HRRZ REG1, (VAL)	TOP PIECE
01300		ADD REG2, REG1		SUM OF PIECES
01400		CAML REG2, MINBLT
01500		JRST GOTIT
01600		SUB VAL, REG1
01700		JRST NEXTXWD
01800	GOTIT	HLRE REG1, (VAL)	DISTANCE TO NEXT RA
01900		ADD REG1, VAL		LOCATION OF IT
02000		PUSH P, VAL
02100		PUSH P, (REG1)
02200		HRLI VAL, 1(VAL)	BLT SOURCE
02300		HRRI VAL, 1(P)		BLT DESTINATION
02400		HRL REG2, REG2		[SIZE,,SIZE]
02500		SUB REG1, P		RA LOC - (OLD P + 4)
02600		ADD P, REG2
02700		JUMPGE P, STACKOVERFLOW
02800		BLT VAL, (P)		** BLT **
02900		ADD REG1, P		RA LOC - (OLD P + 4) + NEW P
03000		MOVE VAL, =SUCCESS
03100		MOVEM VAL, 4(REG1)	NEW RA LOCATION
03200		JRST @RA		RETURN FROM DPNT
03300	
03400	27 INSTRUCTIONS + THE BLTING + 5 INSTRUCTIONS PER PIECE MOVED